import type { EamEquipmentMaintainProgram } from "@/pages/eam/maintainProgram/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
	//项目名称
	name?: string;
	//项目类型
	type?: string;
	//周期类型
	periodType?: string;
	//当前页码
	page: number;
	//每页数量
	pageSize: number;
}

export interface PageListRes {
	//总记录数
	total: number;
	//数据列表
	records: EamEquipmentMaintainProgram[];
}

const pageList = (data: PageListReq): Promise<PageListRes> =>
	apiClient.post({
		url: "/eam/maintain/program/pageList",
		data,
	});
const getInfo = (id: React.Key): Promise<EamEquipmentMaintainProgram> =>
	apiClient.get({
		url: `/eam/maintain/program/${id}`,
	});

const add = (data: EamEquipmentMaintainProgram): Promise<EamEquipmentMaintainProgram> =>
	apiClient.post({
		url: "/eam/maintain/program",
		data,
	});

const update = (data: EamEquipmentMaintainProgram): Promise<EamEquipmentMaintainProgram> =>
	apiClient.put({
		url: "/eam/maintain/program",
		data,
	});

const remove = (ids: React.Key[]): Promise<void> =>
	apiClient.delete({
		url: "/eam/maintain/program",
		params: {
			ids: ids.join(","),
		},
	});
export const eamEquipmentMaintainProgramService = {
	pageList,
	getInfo,
	add,
	update,
	remove,
};

export default eamEquipmentMaintainProgramService;
